﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BalanceManager.Helpers
{
    public class TreeNode<T>
    {
        public ObservableCollection<TreeNode<T>> Children { get; private set; }

        public T Item { get; set; }

        public TreeNode(T item)
        {
            Item = item;
            Children = new ObservableCollection<TreeNode<T>>();
        }

        public TreeNode<T> AddChild(T item)
        {
            var nodeItem = new TreeNode<T>(item);
            Children.Add(nodeItem);
            return nodeItem;
        }

        public void AddChildren(ObservableCollection<TreeNode<T>> children)
        {
            foreach (var child in children)
            {
                Children.Add(child);
            }
        }
    }
}
